<link rel="stylesheet" href="./css/jquery.my-message.1.1.css" />
<script src="./js/jquery-1.11.0.min.js"></script>
<script src="./js/utils.js"></script>
<script type="text/javascript">
  redirectToMobile()
</script>
<div class="header">
  <!--顶部小广告图-->
  <!-- <div class="header-banner">
    <a href="" target="_blank">
      <div class="header-banner-img"></div>
    </a>
    <div class="wrapper">
      <img src="./image/icon/index_gb_icon.png" class="header-banner-close" id="header-banner-close" alt="汇融名企" />
    </div>
  </div> -->
  <div class="header-top">
    <div class="wrapper align-left">
      <div class="top-left">
        <span
          >您好！欢迎访问<strong>汇融名企</strong>网，共享优质商业资源！
        </span>
        <span>|</span>
        <div class="location">
          <img src="./image/icon/index_address_icon.png" alt="汇融名企" />
          <span class="location-text" id="location">定位中</span>
        </div>
      </div>
      <!-- <div class="service">
        <img src="./image/icon/index_kfrx_icon.png" alt="汇融名企" />
        <span style="margin-left:5px; ">客服热线：400-109-8108</span>
        <span style="margin-left: 22px;"
          ><a
            style="color: unset;cursor:pointer;"
            onclick="window.open('http://wpa.qq.com/msgrd?v=3&uin=930522648&site=在线客服&menu=yes');"
            >客服QQ：930522648</a
          ></span
        >
      </div> -->

      <div class="location-container">
        <div class="location-nav">
          <div class="location-nav-item actived-location" id="city-1">
            热门城市
          </div>
          <div class="location-nav-item" id="city-2">
            ABCDE
          </div>
          <div class="location-nav-item" id="city-3">
            FGHIJ
          </div>
          <div class="location-nav-item" id="city-4">
            KLMNO
          </div>
          <div class="location-nav-item" id="city-5">
            PQRST
          </div>
          <div class="location-nav-item" id="city-6">
            UVWXYZ
          </div>
        </div>
        <div class="city-container">
          <div class="citys"></div>
          <div class="city-bottom">
            <div class="back">上一页</div>
            &nbsp;|&nbsp;
            <div class="next">下一页</div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="header-top-bg">
    <div class="wrapper">
      <div class="header-mid">
        <a href="/">
          <img
            class="header-left-img"
            src="./image/picture/header_logo.png"
            alt="汇融名企，共享优质商业资源！"
          />
        </a>
        <!-- <img class="header-con-img" src="./image/picture/sologen.png" alt="汇融名企" /> -->

        <div class="header-nav left">
          <a class="header-nav-item activited" id="index">首页</a>
          /
          <!-- <div class="header-nav-item" id="rankingPage">
            名企榜
          </div>
          / -->
          <a class="header-nav-item" id="merchantsJoin">
            <img
              src="./image/icon/index_syhot_icon.png"
              class="header-hot-icon"
              alt="火热招商-汇融名企"
            />火热招商
          </a>
          /
          <!-- <a class="header-nav-item" id="hot-investment">
            火热招商
          </a>
          / -->
          <!-- <div class="header-nav-item" id="project-bidding">
            项目招标
          </div>
          / -->
          <a class="header-nav-item" id="ad-investment">
            广告位招商
          </a>
          /
          <a class="header-nav-item" id="newsCenter">
            名企要闻
          </a>
          /
          <a class="header-nav-item" id="aboutUs">关于我们</a>
        </div>
        <!-- 暂时注释搜索框 -->
        <!-- <div class="search">
          <div class="search-input-container">
            <input
              class="search-input"
              type="text"
              id="search"
              placeholder="大家都在搜：建材最新排行榜单"
            />
            <div class="search-input-search" id="search-input-search">
              <img src="./image/icon/index_sherch_icon.png" alt="汇融名企" />
            </div>
          </div>
          <div class="search-tags">
          热搜: <span class="search-tag">红星照耀中国 </span>
          <span class="search-tag">断舍离暇步</span>
          <span class="search-tag">士童装</span>
          <span class="search-tag">儿童分级阅读</span>
          <span class="search-tag">GAP秒杀</span>
          <span class="search-tag">1元抢</span>
          </div>
        </div> -->
        <!-- <a href="http://www.jinlongyu.cn" target="_blank">
        <img
          class="header-mid-img-right"
          src="./image/picture/home_dbbn_img.png" alt="汇融名企"
      /></a> -->
        <a href="getReward.html"
          ><img
            class="header-mid-img-right"
            src="./image/picture/index_jpsq_icon.gif"
            alt="奖牌申请-汇融名企"
        /></a>
      </div>
    </div>
  </div>
</div>
<!-- <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> -->
<script src="./js/utils.js"></script>
<script src="./js/api.js"></script>
<script src="./js/message.js"></script>
<script src="./js/jquery.my-message.1.1.js"></script>
<script type="text/javascript">
  $(function () {
    initHeader()
  })
  function initHeader() {
    if (location.pathname.split('/')[1].split('.')[0] != 'rankingPage') {
      $('.search').css('display', 'inline-block')
    } else {
      $('.search').hide()
    }
    var historyPath
    if (
      document.referrer &&
      (document.referrer.indexOf('chmqlive') != -1 ||
        document.referrer.indexOf('39.107.45.63') != -1)
    ) {
      historyPath = document.referrer
        .split('http://')[1]
        .split('/')[1]
        .split('.')[0]
    } else {
      historyPath = ''
    }
    if (historyPath != 'rankingList') {
      sessionStorage.removeItem('title')
    }
    if (
      !sessionStorage.getItem('city_id') &&
      !sessionStorage.getItem('city_name')
    ) {
      loadJS('http://pv.sohu.com/cityjson?ie=utf-8', function () {
        setTimeout(function () {
          var city_name = returnCitySN['cname'].split('省')[1]
          var city_id = returnCitySN['cid']
          sessionStorage.setItem('city_id', city_id)
          initCity(1, 1, 'hot')
        }, 400)
      })
    } else {
      $('#location').html(sessionStorage.getItem('city_name'))
      $('#search').attr(
        'placeholder',
        '大家都在搜：' +
          sessionStorage.getItem('city_name') +
          '建材最新排行榜单'
      )
      initCity(1, 1, 'hot')
    }
    $('.header-nav').find('a').removeClass('activited')
    var targetId = location.pathname.split('/')[1].split('.')[0] || 'index'
    $('#' + targetId).addClass('activited')
    if (sessionStorage.getItem('title')) {
      $('#search').val(sessionStorage.getItem('title'))
    }
    $('#search-input-search').click(function () {
      var title = $('#search').val()
      sessionStorage.setItem('title', title)
      go('rankingList.html')
    })
    var headerTimer = ''
    $('#search').keydown(function (e) {
      if (headerTimer) {
        return false
      }
      var that = this
      var title = $(that).val()
      if (event.keyCode == 13 && title) {
        headerTimer = setTimeout(function () {
          sessionStorage.setItem('title', title)
          go('rankingList.html')
          headerTimer = ''
        }, 200)
      }
    })
  }
  function loadJS(url, callback) {
    var script = document.createElement('script'),
      fn = callback || function () {}
    script.type = 'text/javascript'

    //IE
    if (script.readyState) {
      script.onreadystatechange = function () {
        if (script.readyState == 'loaded' || script.readyState == 'complete') {
          script.onreadystatechange = null
          fn()
        }
      }
    } else {
      //其他浏览器
      script.onload = function () {
        fn()
      }
    }
    script.src = url
    document.getElementsByTagName('head')[0].appendChild(script)
  }
  $(function () {
    $('.header-nav')
      .find('a')
      .click(function (e) {
        if (e.currentTarget.id == 'index') {
          go('./')
        } else {
          go(e.currentTarget.id + '.html')
        }
      })
    $('#header-banner-close').click(function () {
      $('.header-banner').slideUp('slow')
    })
    $('.location').click(function (e) {
      e.stopPropagation()
      $('.location-container').show()
    })
    $('.location-container').click(function (e) {
      e.stopPropagation()
    })
    $('.next').click(function () {
      if (cityPage + 1 <= pageNum) {
        cityPage += 1
        initCity(cityId, cityPage)
      }
    })
    $('.back').click(function () {
      if (cityPage - 1 > 0) {
        cityPage -= 1
        initCity(cityId, cityPage)
      }
    })
    $('.location-nav-item').click(function (e) {
      if (!$(this).hasClass('actived-location')) {
        var id = e.currentTarget.id
        if (id === 'city-1') {
          initCity(id.split('-')[1], cityPage, 'hot')
        } else {
          $('.citys-item').remove()
          cityId = id.split('-')[1]
          cityPage = 1
          initCity(id.split('-')[1], cityPage, 'else')
        }
        $('.location-nav-item').removeClass('actived-location')
        $(this).addClass('actived-location')
        cityPage = 1
      }
    })
  })
</script>
